package com.caigou.service.impl;

import com.caigou.bean.cms.entity.ArticleProceedInfo;
import com.caigou.mapper.cms.ArticleProceedInfoMapper;
import com.caigou.service.ArticleProceedInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;

@Service("articleProceedInfoService")
@Slf4j
public class ArticleProceedInfoServiceImpl implements ArticleProceedInfoService {

    @Resource
    private ArticleProceedInfoMapper articleProceedInfoMapper;

    @Override
    public int saveArticleProceedInfoData(String articleId, Integer periodsNumber, String layout, String proceedTime, Integer proceedWeChat) {
        ArticleProceedInfo articleProceedInfo = new ArticleProceedInfo();
        articleProceedInfo.setArticleId(articleId);
        articleProceedInfo.setPeriodsNumber(periodsNumber);
        articleProceedInfo.setLayout(layout);
        articleProceedInfo.setProceedTime(proceedTime);
        articleProceedInfo.setProceedWeChat(proceedWeChat);
        return articleProceedInfoMapper.saveArticleProceedInfoData(articleProceedInfo);
    }

    @Override
    public void updateArticleProceedInfo(String articleId, Integer periodsNumber, String layout, String proceedTime, Integer proceedWeChat) {
        ArticleProceedInfo articleProceedInfo = new ArticleProceedInfo();
        articleProceedInfo.setArticleId(articleId);
        articleProceedInfo.setPeriodsNumber(periodsNumber);
        articleProceedInfo.setLayout(layout);
        articleProceedInfo.setProceedTime(proceedTime);
        articleProceedInfo.setProceedWeChat(proceedWeChat);
        articleProceedInfoMapper.updateArticleProceedInfo(articleProceedInfo);
    }

    @Override
    public ArticleProceedInfo loadArticleProceedInfoData(String articleId) {
        return articleProceedInfoMapper.loadArticleProceedInfoData(articleId);
    }

    @Override
    public int deleteArticleProceedInfoByArticleId(String articleId){
        return articleProceedInfoMapper.deleteArticleProceedInfoByArticleId(articleId);
    }
}
